package com.example.mapping.controller;

import com.example.mapping.common.core.ResultResponse;
import com.example.mapping.dto.TestDto;
import com.example.mapping.utils.JacksonUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 测试
 *
 * @author baoyoujia
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json")
    public ResultResponse<ObjectNode> test(HttpServletRequest request) throws IOException {
        String requestStr = IOUtils.toString(request.getReader());
        log.info("request: {}", requestStr);
        ObjectNode objectNode = JacksonUtils.parseObject(requestStr, ObjectNode.class);
        return ResultResponse.buildSuccess(objectNode);
    }
}
